package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.portal.domain.PmsCommentOrderReq;
import com.macro.mall.portal.util.OssUtil;
import com.macro.mall.model.PmsCommentLabel;
import com.macro.mall.model.PmsCommentOrder;
import com.macro.mall.model.PmsCommentViewFile;
import com.macro.mall.portal.service.PmsCommentOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author：贾维斯
 * @Description: 描述
 * @name：PmsCommentOrderController
 * @Date：2024/10/30 16:19
 */

@Controller
@Tag(name = "PmsCommentOrderController", description = "评论信息管理")
@RequestMapping("/member/attention")
public class PmsCommentOrderController {
    @Autowired
    private PmsCommentOrderService pmsCommentOrderService;
    @Autowired
    private OssUtil ossUtil;

    @Operation(summary = "保存评论信息")
    @RequestMapping(value = "/addComment", method = RequestMethod.POST)
    @ResponseBody
    public void add(@RequestBody PmsCommentOrderReq pmsCommentOrderReq) {
        pmsCommentOrderService.addCommentOrder(pmsCommentOrderReq);
    }

    @Operation(summary = "添加标签信息")
    @RequestMapping(value = "/addLabel", method = RequestMethod.POST)
    @ResponseBody
    public void add(@RequestBody PmsCommentLabel pmsCommentLabel) {
        pmsCommentOrderService.addCommentLabel(pmsCommentLabel);
    }

    @Operation(summary = "添加视图文件信息")
    @RequestMapping(value = "/addFile", method = RequestMethod.POST)
    @ResponseBody
    public String add(@RequestBody MultipartFile multipartFile) {
        String s = ossUtil.uploadMultipartFile(multipartFile);
        return s;
    }

    /**
     * 有问题
     * @param skuId
     * @return
     */
    @Operation(summary = "查询评论信息")
    @GetMapping("/findComment/{skuId}")
    public CommonResult<PmsCommentOrder> findComment(@PathVariable Integer skuId) {
       return pmsCommentOrderService.findComment(skuId);
    }
}
